package com.example.archive.controller;

import com.example.archive.entity.Tag;
import com.example.archive.service.TagService;
import com.example.archive.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/tag")
public class TagController {

    @Autowired
    private TagService tagService;

    @PostMapping("/add")
    public Result<Boolean> addTag(@RequestBody Tag tag) {
        return tagService.addTag(tag);
    }

    @PutMapping("/update")
    public Result<Boolean> updateTag(@RequestBody Tag tag) {
        return tagService.updateTag(tag);
    }

    @DeleteMapping("/delete/{tagId}")
    public Result<Boolean> deleteTag(@PathVariable Integer tagId) {
        return tagService.deleteTag(tagId);
    }

    @GetMapping("/list")
    public Result<List<Tag>> listTags(String search) {
        return tagService.listTags(search);
    }
} 